<?php
namespace Home\Controller;

use Think\Controller;

class IndexController extends CommonController
{
    public function index()
    {
        $str = 'IP地址：'.getClientIP().' 访问了仿layUI社区前端系统';
        $email = '';
        $emailtitle = '有第三方访问了仿layUI社区前端系统';
        $mail = actmail($email, $emailtitle, $str);
        if (!$mail['error']) {
            $sql = "select t4.uid,t4.uname,t5.avatar,t1.qid,t1.title,t1.qtime,t3.category,t2.num_of_ans,t2.views,t2.excellent,t2.top from question t1 left join question_ext t2 on t1.qid=t2.qid left join qcategory t3 on t1.cag_id=t3.cag_id left join users t4 on t1.uid=t4.uid left join users_ext t5 on t1.uid=t5.uid order by t1.qid desc limit 0,5";
            $qlist = M()->query($sql);
            $linksql = 'select link,title from links order by link_sort desc,id';
            $llist = M()->query($linksql);
            $viewsRank = $this->viewsRank();
            $ansnumRank = $this->ansnumRank();
            $userAnsnum = $this->userAnsnum();
            $this->assign('qlist', $qlist);
            $this->assign('llist', $llist);
            $this->assign('viewsRank', $viewsRank);
            $this->assign('ansnumRank', $ansnumRank);
            $this->assign('userAnsnum', $userAnsnum);
            $this->display();
        } else {
            var_dump($mail);
        }
    }
}
